package com.kma.summer2012.client.view.authorization;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.*;
import com.kma.summer2012.client.presenters.authorization.PasswordRecoveryPresenter;
import com.kma.summer2012.client.styles.style2.Recources;

public class PasswordRecoveryView extends Composite implements PasswordRecoveryPresenter.Display {

    interface PasswordRecoveryViewUiBinder extends UiBinder<Widget, PasswordRecoveryView> {
    }

    private static PasswordRecoveryViewUiBinder ourUiBinder = GWT.create(PasswordRecoveryViewUiBinder.class);

    @UiField
    protected TextBox mailBox;

    @UiField
    protected Button cancelButton;

    @UiField
    protected Button continueButton;

    @UiField
    protected Label textResult;

    @UiField
    protected Label mailLabel;


    public PasswordRecoveryView() {
        HTMLPanel rootElement = (HTMLPanel) ourUiBinder.createAndBindUi(this);
        cancelButton.addStyleName(Recources.INSTANCE.styles().Caption());
        continueButton.addStyleName(Recources.INSTANCE.styles().Caption());
        initWidget(rootElement);
        this.mailLabel.setText("E-mail address:");
    }

    @Override
    public HasClickHandlers getCancelButton() {
        return this.cancelButton;
    }

    @Override
    public HasClickHandlers getContinueButton() {
        return this.continueButton;
    }

    @Override
    public String getMailBox() {
        return this.mailBox.getValue();
    }

    @Override
    public void setMailBox(String text) {
        this.mailBox.setValue(text);
    }

    public void setTextResult(String textResult) {
        this.textResult.setText(textResult);
    }

    public void hideAll() {
        this.mailBox.setVisible(false);
        this.continueButton.setVisible(false);
        this.mailLabel.setVisible(false);
        this.cancelButton.setText("Home");
          /*
          *
          *
          * set position of fields???
          *
           */
        this.textResult.setText("To change your password follow the link that was sent to your e-mail");
    }

    public Widget asWidget() {
        return this;
    }
}